<?php
header('Content-type:text/html;charset=utf8');
/**
 * xysc users Version1.0
 * ==================================
 * Copy 2016-2017
 * Web:www.xjh7.com
 * ==================================
 * Author:xjh
 * Date:2016-4-24
*/
/**
 * 
 * 后台订单控制器
 * @author xjh
 *
 */
class OrderController extends Controller{
	/**
	 * 访问控制过滤
	 * @author xjh
	 */
	function filters(){
		return array(
			'accessControl'
		);
	}
	/**
	 * 具体方法访问具体条件
	 */
	function accessRules(){
		return array(
			array(
				'allow',
				'actions'=>array(),
				'users'=>array('@'),//登陆系统的用户
			),
//			array(
//				'deny',
//				'users'=>array('*'),//所有用户
//			),
		);
	}
	/**
	 * 顶部信息
	 * 
	 */
	function actionOrderTop(){
		$order_model = new Order();
		$order_status_info = $order_model->getOrderStatus();
		$this->renderPartial('orderTop',array('order_status_info'=>$order_status_info));
	}
	
	/**
	 * 订单展示
	 */
	function actionOrder(){
		$order_model = new Order();
		
		if($_POST['order_status_id'] == 999 && empty($_POST['order_no'])){
			$order_info = $order_model->all(Yii::app()->user->id);
		}else{
			$order_info = $order_model->pageSearch(Yii::app()->user->id,$_POST['order_no'],$_POST['order_status_id']);
		}
		

		$order_status = $order_model -> getOrderStatus();
		$express_info = $order_model->getAllExpress();
		$active = array(
			0=>'是',
			1=>'否',
		);
		$this->renderPartial('order',array('order_info'=>$order_info,'express_info'=>$express_info,'active'=>$active,'order_status'=>$order_status));
		
	}
	
/**
	 * 订单信息修改
	 */
	function actionupdorder(){
		
		$order_model = new Order();
		for ($i=0;$i<count($_POST['goods_ids']);$i++) { 
			//更新实付款和排序
			$row = $order_model->updOrder($_POST['order_no'][$i],$_POST['goods_ids'][$i],$_POST['order_status'][$i],$_POST['price'][$i]);
			if(!$row) continue;
		}
		$this->redirect('./index.php?r=backweb/order/order');
			
	}
	
	
	
	
	
}
?>